<script>
    var base_url            = 'http://works:8080';
  var jq = jQuery.noConflict();
function checkContent() {
    var sCheck = "";
if (jq('#full_name').length > 0) {
       sCheck= replaceTag(trim(jq('#full_name').val()));
        jq('#full_name').val(sCheck);
        if (trimAll(sCheck) == '') {
          //  alert('Bạn chưa nhập họ tên.');
          //  jq('#full_name').focus();
          //  return false;
        }
        else if (sCheck.length > 100) {
            alert('Họ tên không quá 100 ký tự.');
            jq('#full_name').focus();
            return false;
        }
    }

 var strpost = 'full_name=' + jq('#full_name').val();
    strpost += '&txtemail=' + jq('#txtemail').val();
    strpost += '&password=' + jq('#password').val();
    

jq.ajax({
            type: "POST",
            cache: false,
            url: base_url+ "/dang-ky/them-tai-khoan",
            data: strpost,
            timeout: 600000,
            error: function(xhr, ajaxOptions, thrownError) {
                alert("có lỗi xảy ra");
            },
            success: function(data) {
                //alert(strpost);
            }
        });


}

function checkexitsEmail(){

     if (jq('#txtemail').length > 0) {
        sCheck = replaceTag(trim(jq('#txtemail').val()));
        jq('#txtemail').val(sCheck);
        if (trimAll(sCheck) == '') {
            alert('Bạn chưa nhập Email.');
            jq('#txtemail').focus();
            return false;
        }
        else if (sCheck.length > 50) {
            alert('Email không quá 50 ký tự.');
            jq('#txtemail').focus();
            return false;
        }
        else if (!checkEmail(sCheck)) {
            alert('Email không đúng định dạng.');
            jq('#txtemail').focus();
            return false;
        }
    }



    jq.ajax({
            type: "POST",
            cache: false,
            url: base_url+ "/dang-ky/kiem-tra-email",
            data: 'email='+jq('#txtemail').val(),
            timeout: 600000,
            error: function(xhr, ajaxOptions, thrownError) {
                alert("có lỗi xảy ra");
            },
            success: function(data) {
                alert(data);
            }
        });


}

function checkEmail(txt) {
    txt = trim(txt).toLowerCase();
    var patt = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}$/;
    return (txt.match(patt) != null);
}
function trim(iStr) {
    if (iStr.length > 0) {
        while (iStr.charCodeAt(0) <= 32)
            iStr = iStr.substr(1);
        while (iStr.charCodeAt(iStr.length - 1) <= 32)
            iStr = iStr.substr(0, iStr.length - 1);
    }
    return iStr;
}

function trimAll(iStr) {
    if (iStr.length > 0) {
        while (iStr.charCodeAt(0) <= 32)
            iStr = iStr.substr(1);
        while (iStr.charCodeAt(iStr.length - 1) <= 32)
            iStr = iStr.substr(0, iStr.length - 1);
    }
    return iStr.replace(/ |&nbsp;/gi, '');
}

function replaceTag(txt) {
    txt = txt.replace(/</gi, '');
    txt = txt.replace(/>/gi, '');
    txt = txt.replace(/&/gi, '');
    return txt;
}
</script>

<form name="frmAdd" id="frmAdd" method="post" enctype="multipart-formdata">
        <fieldset>
        <legend>Member Register</legend>

        <label>Tên truy cập</label><input type="text" name="full_name" value="" id="full_name" size="30"><br>

         <label>Email</label><input type="text" name="txtemail" value="" id="txtemail" size="30"><br>
         <lable><a href="javascript:void(0);" onclick="checkexitsEmail();">check email tồn tại</a></labale>
        <label>Re-Email</label><input type="text" name="txtreemail" value="" id="txtreemail" size="30"><br>

        <label>Password</label><input type="password" name="password" value="" id="lname" size="30"><br>

        <label>Re-Password</label><input type="password" name="repassword" value="" id="lname" size="30"><br>

      
        
        <label>&nbsp;</label> <input type="button" name="ok" value="Register" onclick="return checkContent();"><br>

        </fieldset>
    </form>